//
//  ButtomViewController.m
//  NumLot
//
//  Created by luotao on 12-8-12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "ButtomViewController.h"
#import "TouchImage.h"
#import "Cons.h"
#import "MiddleButtomTouchListener.h"
@implementation ButtomViewController
@synthesize leftButtomImageView;
/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
 // Custom initialization
 }
 return self;
 }
 */

-(id)init{
	if(!(self=[super init])){
		return nil;
	}
	leftButtomImageViews=[[NSMutableArray alloc] init];
	middleButtomImageViews=[[NSMutableArray alloc]init];
    
	viewControllerListeners=[[NSMutableArray alloc]init];
	return self;
}

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	[super loadView];
	self.view.frame = CGRectMake(0, 430, 320,50);
	self.view.backgroundColor=[UIColor clearColor];
	
	TouchImage *image1 = [[TouchImage alloc] initWithImage:[UIImage imageNamed:@"fn_a_button.png"]];
	image1.frame=CGRectMake(0, 0, 110, 50);
	image1.eventCallback=self;
	image1.tag=TAG_BTM_MENU1;
	[self.view addSubview:image1];
	image1.touchEnd=@selector(fireMovedEvent:srcObject:);
	
	
	UIImageView *image11 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fn_a_name.png"]];
	image11.frame=CGRectMake(20, 9, 65, 25);
	
	[self.view addSubview:image11];
	
	
	
	TouchImage *image2 = [[TouchImage alloc] initWithImage:[UIImage imageNamed:@"fn_b_button.png"]];
	image2.frame=CGRectMake(110, 0, 110, 50);
	image2.eventCallback=self;
	image2.tag=TAG_BTM_MENU2;
	[self.view addSubview:image2];
	image2.touchEnd=@selector(fireMovedEvent:srcObject:);
	
	
	UIImageView *image22 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fn_b_name.png"]];
	image22.frame=CGRectMake(130, 9, 75, 25);
	
	[self.view addSubview:image22];
	
	
	TouchImage *image3 = [[TouchImage alloc] initWithImage:[UIImage imageNamed:@"fn_c_button.png"]];
	image3.frame=CGRectMake(220, 0, 110, 50);
	
	[self.view addSubview:image3];
	
	
	UIImageView *image33 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"button1_name_login.png"]];
	image33.frame=CGRectMake(245, 9, 50, 25);
	
	[self.view addSubview:image33];
	
}


-(void) fireMovedEvent:(id) tag srcObject:(UIView *) src{
	for (id<ControllerEventListener> listener in viewControllerListeners) {
		[listener doEvent:self eventType:src.tag];
	}
}

//加入事件监听
-(void) addControllerListener:(id<ControllerEventListener>) controllerListener{
	[viewControllerListeners addObject:controllerListener];
}

/*
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
 [super viewDidLoad];
 }
 */

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	//	 [menuView release];
	[leftButtomImageView release];
	
	[leftButtomImageViews release];
	[middleButtomImageViews release];
	[viewControllerListeners release];
	[lineV1 release];
	[lineV2 release];
	[lineV3 release];	
	[lineH release];	
    [super dealloc];
}


@end
